using System;
using System.Data;
using System.Configuration;
using System.Collections;
using System.Web;
using System.Web.Security;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;
using System.Web.UI.HtmlControls;
using Dcms.Common;
using Dcms.BLL;
using Dcms.Model;

public partial class UserControl_SysControl_ProductNextPage : System.Web.UI.UserControl
{
    protected void Page_Load(object sender, EventArgs e)
    {
        try
        {
            string strProductID = Request.QueryString["ProductsID"] + "";
            if (strProductID != "")
            {
                int intProductID = Convert.ToInt32(strProductID);
                Dcms_ProductsBLL bllDcms_Products = new Dcms_ProductsBLL();
                Dcms_ProductsModel etDcms_Products = bllDcms_Products.GetModelByID(intProductID);
                //string strSqlPrev = string.Format("select top 1 * from Dcms_Products where Products_ID > {0} and Products_CateID={1} order by Products_ID ", etDcms_Products.Products_ID, etDcms_Products.Products_CateID);
                string strSqlPrev = string.Format("select top 1 * from Dcms_Products where Products_ID > {0} order by Products_ID ", etDcms_Products.Products_ID);
                DataTable dtPrev = DcmsDataBaseHelper.ExecuteTable(strSqlPrev, CommandType.Text, null);
                if (dtPrev != null && dtPrev.Rows.Count > 0)
                {
                    ltPrev.Text = string.Format("<a href='products_info.aspx?ProductsCateId={0}&ProductsId={1}'>[上一个产品]    </a>",dtPrev.Rows[0]["Products_CateId"],dtPrev.Rows[0]["Products_ID"]);
                }
    // string strSqlNext = string.Format("select top 1 * from Dcms_Products where Products_ID < {0} and Products_CateID={1} order by Products_ID desc ", etDcms_Products.Products_ID, etDcms_Products.Products_CateID);           
                string strSqlNext = string.Format("select top 1 * from Dcms_Products where Products_ID < {0} order by Products_ID desc ", etDcms_Products.Products_ID);
                DataTable dtNext = DcmsDataBaseHelper.ExecuteTable(strSqlNext, CommandType.Text, null);
                if (dtNext != null && dtNext.Rows.Count > 0)
                {
                    ltNext.Text = string.Format("<a href='products_info.aspx?ProductsCateId={0}&ProductsId={1}'>   [下一个产品]</a>",dtNext.Rows[0]["Products_CateId"], dtNext.Rows[0]["Products_ID"]);
                }

            }
        }
        catch (Exception ex)
        { }
    }
}
